package com.qf.config;

import com.qf.pojo.User;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Java配置类
 *   使用Java代码完成
 *       原来的配置:<bean id=user class="com.qf.pojo.User">
 *                   <property name="id" value="123"></property>
 *                   <property name="name" value="123"></property>
 *                </bean>
 * @author lixu
 */
@Configuration //相当于原来 spring-context.xml
public class UserConfig {
    /**
     * 最新版SpringBoot的Java配置类
     *  取代的原来的：
     *    <bean id=user1 class="com.qf.pojo.User">
     *  *                   <property name="id" value="123"></property>
     *  *                   <property name="name" value="123"></property>
     *  *                </bean>
     * @return
     *
     *  @Bean(value = "user1") value: 将方法对应的id=user1进行 修改
     */
    @Bean(value = "user11")
    public User user1(){
        User user = new User();
        user.setName("xixi");
        user.setId(123);
        return user;
    }
    @Bean(value = "user22")
    public User user2(){
        User user = new User();
        user.setName("xixi");
        user.setId(123);
        return user;
    }
}
